crudcontroller

Create-read-update-delete operations on every tables in DB by a single controller

This extension implements CRUD operations on the DB tables using a single controller.

=============================
Copyright (c) 2009 by Vladimir Kovarsky
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of Vladimir Kovarsky nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=============================

###Requirements
* Yii 1.0.2 or above - tested only at this version

###WARNING!!! 
Be careful with access control! 
You should set restricted access to this controller, or list allowed models in filters, or organize access control to tables at the database level (if possible).
Otherwise one can manipulate with your forbidden datatables over it!

###Installation
* Extract the release catalogue 'crud' under `protected/extensions`

* Add to your 'config/main':
[php]
     'controllerMap'=>array(
        'crud'=>array(
           'class'=>'application.extensions.crud.CrudController',
        )
    ),

     'components'=>array(
         ..............
        'crudMessages'=>array(
            'class'=>'CPhpMessageSource',
            'basePath'=>'protected/extensions/crud/messages',
        ),     
         ..............

The last ('crudMessages') is needed if you have created corresponding message file 'yii.php' and dispose it in the corresponding language directory. 
At present only Russian translation is available.

* Define 'pluralName' property to all of your models you want to manipulate over this controller - if wanna get nice titles!

* Define all needed relaitons in your models via Model::relations.
  Notice! Only 'BELONGS_TO' type taken into account in this version.

* View files 'list.php', 'createUpdate.php' use CSS classes defined in 'main.css', registered in layout. 
  You may redefine them in your own css-file and register this one (after publishing). 

###Usage
call by the adddress:
{baseUrl}/crud/{action}/model/{modelName}[/id/{recordId}],

where
{action} = create|list|update|delete|
{modelName} - your model's name in lowercase
    if needed (for update & delete), set value of record id you want to update or delete:
{recordId} - record id (if needed)

###Restrictions
At present can work with models having:
1) ONLY 'BELONGS_TO' relations;
2) ONE primary key named 'id';
3) refered table MUST have a field named 'name' - that is the field which is displayed in the relation

I learnt from someone that references can be emulated even on MyISAM tables using 'COMMENT' SQL declaration, but I didn't check. 
It works definitely on InnoDB with real references - this is a fact, and it's enough for me...
